@extends("agent.layouts.main")
<style>
    .card-body .form-group {
        width: 47%;
    }
    @media screen and (max-width: 1024px) {
        .card-body .form-group {
            width: 100% !important;
        }
    }
    .show-item {
        top: 40px;
        width: 100%;
        background: white;
        overflow: hidden;
        display: none;
    }
    .showMsg li {
        padding-bottom: 5px;
        cursor: pointer;
        padding: 10px 8px;
        margin: 2px 0;
    }
    .showMsg li:hover {
        background-color: #f2f2f2;
    }
</style>
@section("content")
    <div class="container-fiuld p-3" id="app">
        <div class="card">
            <div class="card-body">
                <div class="pt-2 pb-2 d-flex justify-content-between align-items-center"
                     style="background-color:#f2f2f2;font-size:18px;">
                    <h4 class="pl-2">申请提现</h4>
					<a href="{{ route('commission') }}" class="btn btn-link">返回</a>
                </div>
                <form class="layui-form mt-3">
                    <div class="form-group d-flex">
                        <label for="pwd" class="w-50 text-right mr-3" style="line-height:30px">可提现金额:</label>
                        <input type="text" class="form-control" name="crray" lay-verify="required" value="{{$guser->balance}}" readonly>
                    </div>
                    <div class="form-group d-flex">
                        <label for="pwd" class="w-50 text-right mr-3" style="line-height:30px">提现金额:</label>
                        <input type="text" class="form-control" name="money" lay-verify="required|number" >
                    </div>


                    <div class="" style="margin-left:10rem">
                        <button type="button" class="btn btn-primary ml-5" lay-submit  lay-filter="applyAdd" data-url="{{ route('applySave') }}" data-type="POST">申请提现</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
@section("js")
    <script>

        //数据操作
        layui.use(["form", "layer"], function () {
            var form = layui.form, $ = layui.$, layer = layui.layer;
            })

        layui.use(['form', 'ori'], function () {
            var form = layui.form,
                ori = layui.ori,
                $ = layui.$;
            form.on('submit(applyAdd)', function (data) {
                var money = $('[name="money"]').val();
                var crray = $('[name="crray"]').val();
				var reg = /^\d+(\.\d{1,2})?$/;
				if(!reg.test(money)){
					layer.msg('金额输入错误，最多能输入两位小数');
                    return false;
				}
                if(parseFloat(money) > parseFloat(crray)){
                    layer.msg('最多只能提现'+crray);
                    return false;
                }
                ori.submit($(this), data.field, function () {
                    //window.location.reload();
					window.location.href = "{{ route('commission') }}";
                });
                return false;
            });
        })
    </script>
@endsection